﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DTO;
using DAO;

namespace BUS
{
   public class GioHang
    {
       private List<SanPhamGioHang > dsSanPhamKM_Mua;
       BanHang_LinQDataContext linQBanHang = new BanHang_LinQDataContext();
        public List<SanPhamGioHang > DsSanPhamKM_Mua
        {
            get { return dsSanPhamKM_Mua; }
            set { dsSanPhamKM_Mua = value; }
        }
        public void KhoiTaoGioHang()
        {
            dsSanPhamKM_Mua = new List<SanPhamGioHang >();
        }
        public void ThemSanPham(SanPhamGioHang  chiTiet)
        {
            SanPhamGioHang  ct;
            ct = dsSanPhamKM_Mua.SingleOrDefault(k =>k.MaKhuyenMai == chiTiet.MaKhuyenMai);
            if (ct != null)
            {
                ct.SoLuong += chiTiet.SoLuong;
            }
            else
            {
                dsSanPhamKM_Mua.Add(chiTiet);
            }
        }
    }
}
